#include "..\..\NahidaProject-UnitTest\Sources\NahidaUnitTest.h"

#include "..\Sources\ODBC.h"

TESTCASE(ODBCTest) {
	NahidaProject::ODBC odbc;
	std::cout << odbc.Connect((SQLCHAR*)"SQL Server Datasource", (SQLCHAR*)"sa", (SQLCHAR*)"081105") << std::endl;
	std::cout << odbc.ExecuteSQLWithoutResult((SQLCHAR*)"SELECT @@VERSION;") << std::endl;
	std::vector<std::vector<std::string>> a = odbc.ExecuteSQLWithResult((SQLCHAR*)"SELECT * FROM Northwind.dbo.Products;");
	
	for (std::vector<std::string> item1 : a) {
		for (std::string item2 : item1) {
			std::cout << item2 << std::endl;
		}
	}

	odbc.RegisterTransaction("Transaction1", [&]() {
		odbc.ExecuteSQLWithoutResult((SQLCHAR*)"DROP TABLE dbo.Products;");
	});

	odbc.InvokeTransaction("Transaction1");
	odbc.UndoTransaction();

	odbc.Close();
}

int main() {
	NahidaProject::NahidaUnitTest::RunAllTests();
	return 0;
}